package com.hwang.demo2;

import java.util.Scanner;

public class guess_game {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        double dou = Math.random()*10;
        int num = (int)dou + 1;
        System.out.println("请输入1个范围为1-10的整数：");
        while (true){
            int input = sc.nextInt();
            if (input>num&&input<11){
                System.out.println("当前数值过大，请重新输入！");
            }else if (input<num&&input>0){
                System.out.println("当前数值过小，请重新输入！");
            }else if (input==num){
                System.out.println("恭喜你猜中了，正确数值为："+num);
                System.out.println("游戏结束！");
                break;
            }
        }
    }
}
